from time import sleep

from page_locators.reward_locator import RewardLocator as RL
from page_locators.career_management_locator import CareerManagementLocator as CML
from common.base_page import BasePage 
from test_datas.career_manage_datas import *
from test_datas.pic_data import *
from test_tools.class_mysql import Conn

class Reward(BasePage):

    def __init__(self, driver):
        super().__init__(driver)
        self.conn = Conn("root", "diama_239", "192.168.1.239", "iconductor_media")

    def reward_menu_click(self, username, password):
        self.input(CML.username_loc, username, '用户名输入失败截图')
        self.input(CML.password_loc, password, '密码输入失败截图')
        code = self.get_code(CML.captcha_img, '验证码图片定位', 'src')
        self.input(CML.captcha, code, '验证码输入')
        self.click(CML.loginsbt, '登录按钮点击失败截图')
        sleep(1)
        self.switch_window()
        sleep(1)
        self.click(RL.teacher_manage, "教职工信息管理点击跳转")
        sleep(0.5)
        self.click(RL.reward_menu, "奖励菜单点击")

    def add_reward(self):
        sleep(1)
        self.click(RL.reward_menu, "奖励菜单点击")
        sleep(1)
        self.click(RL.add_reward, "添加奖励点击")
        
    def name_error1(self):
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, "dsgregeg", "名称输入框定位输入")
        self.wait(RL.name_tips, 10, 1)

    def name_error2(self):
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, big_string, "名称输入框定位输入")
        self.wait(RL.name_tips, 10, 1)

    def name_error3(self):
        self.click(RL.reward_type, "奖励类别下拉框定位点击")
        self.click(RL.scientific_research, "科研工作定位点击")
        self.input(RL.reward_name, "奖励", "奖励名称定位输入")
        self.click(RL.sure, "确定按钮定位点击")

    def name_error4(self):
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, ' ', "名称输入框定位输入")
        self.wait(RL.name_tips, 10, 1)

    def add_teacherinfo(self):
        self.click(CML.career_management, "入职管理定位点击")
        self.click(CML.add_teacher, "添加教师点击跳转")
        self.input(CML.name, '亚瑟', "名称输入框定位输入")
        self.click(CML.category_faculty, '教职工类别定位点击')
        self.click(CML.fulltime_teacher, "专任教师定位点击")
        self.input(CML.phone, "13000000012", "手机号定位输入")
        self.input(CML.idcard, id18_X, "身份证输入框定位输入")
        self.input(CML.emile, emile_phone, "邮箱输入框定位输入")
        self.input(CML.church, cheles19, "教籍输入框定位输入")
        self.click(CML.sure, "确定按钮点击定位")

    def delete_add_teacherinfo(self):
        self.click(CML.career_management, "入职管理定位点击")
        self.click(CML.del_ys, "列表第一个删除按钮定位点击")
        self.click(CML.continue_del, "继续删除按钮定位点击")
        self.click(CML.check_know, "我已知晓定位点击")
        self.click(CML.sure_dle, '确定删除按钮定位点击')

    def input_name(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, '亚瑟', "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")

    def input_phone(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, '13000000012', "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")

    def input_id(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, id18_X, "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")

    def input_emile(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, emile_phone, "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")

    def input_church(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, cheles19, "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")

    def reward_type_none(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, "亚瑟", "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")
        self.input(RL.reward_name, "奖励", "奖励名称定位输入")
        self.click(RL.sure, "确定按钮定位点击")

    def reward_name_error1(self):
        self.add_reward()
        self.input(RL.reward_name, big_string, "奖励名称定位输入")

    def reward_name_error2(self):
        self.add_reward()
        self.input(RL.reward_name, cheles51, "奖励名称定位输入")

    def reward_name_success1(self):
        self.add_reward()
        self.input(RL.reward_name, cheles50, "奖励名称定位输入")

    def reward_name_success2(self):
        self.add_reward()
        self.input(RL.reward_name, cheles49, "奖励名称定位输入")

    def reward_name_none(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, "亚瑟", "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")
        self.click(RL.reward_type, "奖励类别下拉框定位点击")
        self.click(RL.scientific_research, "科研工作定位点击")
        self.sure_sub()

    def reward_name_space(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, "亚瑟", "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")
        self.click(RL.reward_type, "奖励类别下拉框定位点击")
        self.click(RL.scientific_research, "科研工作定位点击")
        self.input(RL.reward_name, " ", "奖励名称定位输入")
        self.sure_sub()

    def sure_sub(self):
        self.click(RL.sure, "确定按钮定位点击")

    def mustbe_input(self):
        self.add_teacherinfo()
        self.add_reward()
        self.remove_attribute(RL.name, "名称输入框定位", "readonly")
        self.input(RL.name, "亚瑟", "名称输入框定位输入")
        self.click(RL.list1, "名称列表第一个定位点击")
        self.click(RL.reward_type, "奖励类别下拉框定位点击")
        self.click(RL.scientific_research, "科研工作定位点击")
        self.input(RL.reward_name, "优秀奖励", "奖励名称定位输入")

    def reward_level_click(self):
        self.click(RL.reward_level, "奖励等级下拉框定位点击")
        self.click(RL.first_class, "一等奖定位选择")

    def reward_level(self):
        self.mustbe_input()
        self.reward_level_click()
        self.sure_sub()


    def reward_time_input(self):
        self.input(RL.reward_time, "2022-11", "奖励年月定位输入")
        self.click(RL.name, "名称输入框定位点击")

    def reward_time(self):
        self.mustbe_input()
        self.reward_time_input()
        self.sure_sub()

    def reward_area_level_click(self):
        self.click(RL.reward_area_level, "奖励级别下拉框定位点击")
        self.click(RL.school_level, "学校级定位点击")

    def reward_area_level(self):
        self.mustbe_input()
        self.reward_area_level_click()
        self.sure_sub()

    def unit_prizes_error1(self):
        self.add_reward()
        self.input(RL.unit_prizes, big_string, "授奖单位定位输入")

    def unit_prizes_error2(self):
        self.add_reward()
        self.input(RL.unit_prizes, cheles51, "授奖单位定位输入")

    def unit_prizes_success1(self):
        self.add_reward()
        self.input(RL.unit_prizes, cheles50, "授奖单位定位输入")
        sleep(2)

    def unit_prizes_success2(self):
        self.add_reward()
        self.input(RL.unit_prizes, cheles49, "授奖单位定位输入")

    def unit_prizes(self):
        self.input(RL.unit_prizes, "纳吉特数据科技有限公司", "授奖单位定位输入")

    def unit_prizes_space(self):
        self.mustbe_input()
        self.input(RL.unit_prizes, " ", "授奖单位定位输入")
        self.sure_sub()

    def note_error1(self):
        self.add_reward()
        self.input(RL.note, big_string, "备注输入框定位输入")

    def note_error2(self):
        self.add_reward()
        self.input(RL.note, cheles101, "备注输入框定位输入")

    def note_success1(self):
        self.add_reward()
        self.input(RL.note, cheles100, "备注输入框定位输入")

    def note_success2(self):
        self.add_reward()
        self.input(RL.note, cheles99, "备注输入框定位输入")

    def accessory_input_pic(self):
        self.add_reward()
        sleep(1)
        self.upload_file(RL.accessory, getFile_png, "附件定位上传")
        
    def accessory_input_twofile(self):
        self.accessory_input_pic()
        sleep(1)
        self.upload_file(RL.accessory, cover_pic, "附件定位上传")
        
    def accessory_input_txt(self):
        sleep(1)
        self.upload_file(RL.accessory, txt, "附件定位上传")
        
    def accessory_input_excel(self):
        sleep(1)
        self.upload_file(RL.accessory, excel, "附件定位上传")
        
    def accessory_input_zipfile(self):
        sleep(1)
        self.upload_file(RL.accessory, zip_file, "附件定位上传")

    def delete_rewardinfo(self):
        self.click(RL.delete, "列表第一条删除按钮点击")
        self.click(RL.sure_del, "系统提示确认删除按钮点击")
        self.delete_add_teacherinfo()

    def add_reward_scene(self):
        self.mustbe_input()
        self.reward_level_click()
        self.reward_time_input()
        self.reward_area_level_click()
        self.unit_prizes()
        self.input(RL.note, cheles99, "备注输入框定位输入")
        self.upload_file(RL.accessory, getFile_png, "附件定位上传")
        self.sure_sub()

    def edit_sub_click(self):
        self.click(RL.edit, "编辑按钮定位点击")

    def edit(self):
        self.mustbe_input()
        self.sure_sub()
        self.edit_sub_click()

    def edit_sub(self):
        self.mustbe_input()
        self.sure_sub()
        self.edit_sub_click()
        self.clear(RL.reward_name, "清空奖励名称")
        sleep(1)
        self.input(RL.reward_name, "校运动会第一名", "奖励名称定位输入")
        self.sure_sub()




